/*************************************************************************************************
 * Class to represent a perfect triangle. The class inherits perfect polygon. 
 * A perfect polygon is characterized by 3 sides and their length. Its area is (sqrt(3)/4)*(length)^2. 
 *************************************************************************************************/

package geometricElement;

public class PerfectTriangle extends PerfectPolygon {
	
	// members
	private static final double areaConstant = Math.sqrt(3)/4;
	private static final int sides  = 3; // a perfect triangle has 3 sides
	
	// methods
	/*************************************************************************************************
	 * Function name: public PerfectTriangle(int xCord, int yCord, double length)
	 * Input: Position and side's length
	 * Output: None
	 * Function operation: Constructor- creates a new perfect triangle with given values, using 
	 * 					   PerfectPolygon's constructor
	 *************************************************************************************************/
	public PerfectTriangle(int xCord, int yCord, double length) {
		// set members with given value		
		super(xCord, yCord, length, sides);
		// set area according to perfect triangle's method
		setArea(calculateArea());
	}

	/*************************************************************************************************
	 * Function name: public double calculateArea()
	 * Input: None
	 * Output: Circle's area
	 * Function operation: Calculates perfect triangle's area and returns it
	 *************************************************************************************************/
	public double calculateArea() {
		// perfect triangle's area is (sqrt(3)/4)*(length)^2
		return areaConstant*getLength()*getLength();
	}

	/*************************************************************************************************
	 * Function name: public PerfectTriangle clone()
	 * Input: None
	 * Output: Reference to perfect triangle's copy
	 * Function operation: Allocates a new perfect triangle with activating perfect triangle's attributes 
	 * 					   and returns a reference to the copy 
	 *************************************************************************************************/
	public PerfectTriangle clone() {
		return new PerfectTriangle(getXcord(), getYcord(), getLength());
	}

	public String toString() {
		return "Type: PerfectTriangle, " + super.toString();
	}
}
